import pygame as pg
import pymunk as pm
import random
import sys,os

def resource_path(relative_path):
    if getattr(sys, 'frozen', False):
        base_path = sys._MEIPASS
    else:
        base_path = os.path.abspath(".")
        # base_path = os.path.dirname(os.path.abspath(__file__))
    return os.path.join(base_path, relative_path)

class Zombie():
    def __init__(self,parent,healthy = 100):
        self.img = pg.image.load(resource_path("images/Zombies/Zombie.png"))
        self.x = 800
        self.y = random.randint(0,4) * 100 + 90
        self.rect = (self.x,self.y,self.img.get_width(),self.img.get_height())
        self.speed = -0.25
        self.maxhealthy = healthy
        self.healthy = self.maxhealthy
        self.healthbarColor = (0,255,0)
        self.statuses = {}
        self.parent = parent
        self.death = False

    def healthyOnChange(self):
        if self.healthy <= 20:
            self.healthbarColor = (255,0,0)
            if self.healthy <= 0:
                self.death = True
                self.parent.remove(self)
        elif self.healthy > 20 and self.healthy <= 60:
            self.healthbarColor = (255,255,0)
